import * as Cesium from 'cesium';
//导入要使用的材质
import PolylineTrailMaterialProperty from './material/PolylineTrailMaterialProperty';
//导入图片纹理轨迹线
//导入图片纹理轨迹线
import SpritelineMaterialProperty from './material/SpritelineMaterialProperty';
export default class RoadLightLine {
  constructor(viewer) {
    let geoJsonPromise = Cesium.GeoJsonDataSource.load(
      './geojson/roadline.geojson'
    );
    geoJsonPromise.then((dataSource) => {
      // console.log('res', res);
      viewer.dataSources.add(dataSource);
      let entities = dataSource.entities.values;
      let color = new Cesium.Color(0.7, 1.0, 0.7, 1.0);
      //替换材质部分
      let polylineTrailMaterialProperty = new PolylineTrailMaterialProperty(
        color
      );
      let spritelineMaterialProperty = new SpritelineMaterialProperty();
      entities.forEach((item) => {
        let polyline = item.polyline;
        //替换材质
        polyline.material = spritelineMaterialProperty;
      });
    });
  }
}
